package com.example.demo.common.util;

import com.example.demo.common.CodeEnum;

public class EnumUtil {
    //返回的对象实现CodeEnum接口
    public static <T extends CodeEnum> T getByCode(Class<T> enumClass, String code) {
        for (T each : enumClass.getEnumConstants()) {
            if(code.equals(each.getCode())){
                return each;
            }
        }
        return null;
    }
}
